home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Magazine Collection 2001
/
Delphi Magazine Collection 20001 (2001).iso
/
DISKS
/
ISSUE23
/
TIPTRIX
/
LISTING2.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1997-06-17
|
1KB
|
60 lines
LOCBUG.DPR:
program LocBug;
uses
LocBugA;
begin
end.
LOCBUGA.PAS:
unit LocBugA;
interface
{$HINTS OFF} {$WARNINGS OFF} {$ALIGN OFF}
type
TObjectA = class
private
UnusedA: integer; // Should not get hint, and we don't
public
procedure Destroy; // Should not get warning, and we don't
end;
TRecA = record // SizeOf(TRecA) should be 5, and it is
A: char;
L: longint;
end;
implementation
uses
LocBugB;
{.$HINTS OFF} // Remove dots to work around the buggy behavior
{.$WARNINGS OFF}
type
TObjectB = class
private
UnusedB: integer; // Should not get hint, but we do in D3
(sometimes)
public
procedure Destroy; // Should not get warning, but we do
(sometimes)
end;
{.$ALIGN ON} // If you remove the dot, you will get an invalid
typecast below
TRecB = record // SizeOf(TRecA) should be 5, and it is
A: char;
L: longint;
end;
procedure TObjectA.Destroy; begin end;
procedure TObjectB.Destroy;
var
A: TRecA;
begin
TRecB(A).L := 123; // This is Ok because SizeOf(TRecA) =
SizeOf(TRecB)
end;
end.
LOCBUGB.PAS:
unit LocBugB;
interface
implementation
{$HINTS ON} {$WARNINGS ON} {$ALIGN ON}
end.